import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
import _map from "lodash/map";
import _isFunction from "lodash/isFunction";
var _excluded = ["type", "value"];

var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _dec25, _class;

/**
 * SafeInfo.js
 * @date 2018/11/23

 */
import React from 'react';
import { Button, Form, Icon, Input, Modal } from 'antd';
import { Bind } from 'lodash-decorators';
import { routerRedux } from 'dva/router';
import CountDown from 'components/CountDown';
import intl from 'utils/intl';
import { AUTH_HOST } from 'utils/config';
import { getAccessToken, getUserOrganizationId, getSession, encryptPwd } from 'utils/utils';
import { EMAIL, PHONE } from 'utils/regExp';
import notification from 'utils/notification';
import { validatePasswordRule } from "../../utils/validator";
import styles from "./index.less?modules";
import Main from "./components/Main"; // import LineItem from './components/LineItem';

import Content from "./components/Content";
import ModalForm from "./components/ModalForm";
import EditFormModal from "./components/EditFormModal";
import MaxLenItem from "./components/MaxLenItem";
var FormItem = Form.Item;
var formItemLayout = {
  labelCol: {
    span: 5
  },
  wrapperCol: {
    span: 19
  }
}; // const securityLevelStyle = {
//   margin: '10px 0',
// };

var SafeInfo = (_dec = Bind(), _dec2 = Bind(), _dec3 = Bind(), _dec4 = Bind(), _dec5 = Bind(), _dec6 = Bind(), _dec7 = Bind(), _dec8 = Bind(), _dec9 = Bind(), _dec10 = Bind(), _dec11 = Bind(), _dec12 = Bind(), _dec13 = Bind(), _dec14 = Bind(), _dec15 = Bind(), _dec16 = Bind(), _dec17 = Bind(), _dec18 = Bind(), _dec19 = Bind(), _dec20 = Bind(), _dec21 = Bind(), _dec22 = Bind(), _dec23 = Bind(), _dec24 = Bind(), _dec25 = Bind(), (_class = /*#__PURE__*/function (_React$Component) {
  _inherits(SafeInfo, _React$Component);

  var _super = _createSuper(SafeInfo);

  // 渲染 ModalForm 中的 FormItems
  // Modal onOk
  function SafeInfo(props) {
    var _this;

    _classCallCheck(this, SafeInfo);

    _this = _super.call(this, props);
    _this.renderModalFormItems = void 0;
    _this.handleModalFormOk = void 0;
    _this.state = {
      modalProps: {
        visible: false
      } // 模态框属性

    };
    _this.handleModalFormOk = _this.handleModalFormCancelDefault; // 默认是取消

    return _this;
  }

  _createClass(SafeInfo, [{
    key: "componentDidMount",
    value: function componentDidMount() {
      var dispatch = this.props.dispatch; // dispatch({
      //   type: 'userInfo/fetchOpenAccountList',
      // });
      // dispatch({
      //   type: 'personalLoginRecord/fetchRecords',
      //   payload: {
      //     tenantId: getCurrentOrganizationId(),
      //     page: 0,
      //     size: 3,
      //   },
      // });
      // 获取公钥

      dispatch({
        type: 'userInfo/getPublicKey'
      });
    }
  }, {
    key: "render",
    value: function render() {
      var modalProps = this.state.modalProps;
      var _this$props = this.props,
          _this$props$editModal = _this$props.editModalLoading,
          editModalLoading = _this$props$editModal === void 0 ? false : _this$props$editModal,
          editFormModalProps = _this$props.modalProps,
          _this$props$openAccou = _this$props.openAccountList,
          openAccountList = _this$props$openAccou === void 0 ? [] : _this$props$openAccou; // const {step = 'form-key'} = editFormModalProps;
      // 只有在发送验证码后才能点下一步

      var editFormModalOkBtnProps = {};

      switch (editFormModalProps.step) {
        case 'validateOldEmail':
          editFormModalOkBtnProps.disabled = !getSession('user-info-oldEmail');
          break;

        case 'validateOldPhone':
          editFormModalOkBtnProps.disabled = !getSession('user-info-oldPhone');
          break;

        case 'validateNewEmail':
        case 'validateNewPhone':
        case 'validateUnCheckedEmail':
        case 'validateUnCheckedPhone':
          editFormModalOkBtnProps.disabled = !editFormModalProps.captchaKey;
          break;

        default:
          break;
      }

      modalProps.confirmLoading = editModalLoading; // editModalLoading 包含密码的loading

      return /*#__PURE__*/React.createElement("div", {
        className: styles.safe
      }, /*#__PURE__*/React.createElement(Main, {
        title: intl.get('ciam.userInfo.view.title.main.safeSetting').d('安全设置')
      }, /*#__PURE__*/React.createElement(Content, null, this.renderPassword(), this.renderPhone(), this.renderEmail())), openAccountList.length > 0 && /*#__PURE__*/React.createElement(Main, {
        title: intl.get('ciam.userInfo.view.title.subMain.openApp').d('第三方账号绑定'),
        className: styles['open-app']
      }, /*#__PURE__*/React.createElement(Content, null, this.renderOpenApp())), /*#__PURE__*/React.createElement(Main, {
        title: /*#__PURE__*/React.createElement("div", {
          className: styles['login-log']
        }, /*#__PURE__*/React.createElement("div", null, intl.get('ciam.userInfo.view.login.log').d('登录日志')), /*#__PURE__*/React.createElement(Button, {
          key: "bind",
          type: "primary",
          style: {
            marginRight: 5,
            marginBottom: 6
          },
          onClick: this.handleCheckLoginLog
        }, intl.get('ciam.userInfo.view.check').d('查看'))),
        className: styles['open-app']
      }), /*#__PURE__*/React.createElement(ModalForm, {
        modalProps: modalProps,
        renderFormItems: this.renderModalFormItems,
        onOk: this.handleModalFormOk
      }), /*#__PURE__*/React.createElement(EditFormModal, Object.assign({
        width: 500,
        confirmLoading: editModalLoading,
        okButtonProps: editFormModalOkBtnProps
      }, editFormModalProps)));
    } // // security-level
    // renderSecurityLevel() {
    //   const { userInfo: { securityLevelMeaning } } = this.props;
    //   return (
    //     <LineItem
    //       key="securityLevel"
    //       style={securityLevelStyle}
    //       itemLabel={null}
    //       content={
    //         <React.Fragment>
    //           <span className={styles['security-level']}>您当前账号的安全程度</span>
    //           <span>{securityLevelMeaning}</span>
    //         </React.Fragment>
    //       }
    //     />
    //   );
    // }

  }, {
    key: "handleModalFormCancelDefault",
    value: function handleModalFormCancelDefault() {
      this.renderModalFormItems = undefined;
      this.handleModalFormOk = this.handleModalFormOkDefault;
      this.setState({
        modalProps: {
          visible: false
        }
      });
    } // password

  }, {
    key: "renderPassword",
    value: function renderPassword() {
      var _this$props$userInfo = this.props.userInfo,
          userInfo = _this$props$userInfo === void 0 ? {} : _this$props$userInfo;
      var btns = [/*#__PURE__*/React.createElement(Button, {
        key: "update",
        onClick: this.handlePasswordEdit
      }, intl.get('cpaas.common.button.update').d('修改'))];
      var comment = intl.get('ciam.userInfo.view.message.password').d('安全性高的密码可以使账号更安全。建议您定期更换密码，设置一个包含字母，符号或数字中至少两项长度超过6位的密码。');
      var content = '';

      if (userInfo.passwordResetFlag === 1) {
        content = /*#__PURE__*/React.createElement("span", {
          key: "desc",
          className: styles['color-bind']
        }, /*#__PURE__*/React.createElement(Icon, {
          type: "check-circle"
        }), "\xA0", intl.get('ciam.userInfo.view.status.setted').d('已设置'));
      } else {
        content = /*#__PURE__*/React.createElement("span", {
          key: "desc",
          className: styles['color-unbind']
        }, /*#__PURE__*/React.createElement(Icon, {
          type: "info-circle"
        }), "\xA0", intl.get('ciam.userInfo.view.status.noSetPassword').d('管理员设置的初始密码,请修改'));
      }

      return /*#__PURE__*/React.createElement(MaxLenItem, {
        className: styles['max-len-item-content-wrapper-safe'],
        itemIcon: null,
        description: intl.get('ciam.userInfo.model.user.loginPassword').d('登录密码'),
        content: content,
        comment: comment,
        btns: btns
      });
    }
  }, {
    key: "handlePasswordEdit",
    value: function handlePasswordEdit() {
      var dispatch = this.props.dispatch;
      this.renderModalFormItems = this.renderPasswordFormItems;
      this.handleModalFormOk = this.handlePasswordUpdate;
      this.setState({
        modalProps: {
          title: intl.get('ciam.userInfo.view.message.title.form.password').d('更改密码'),
          visible: true,
          onCancel: this.handleModalFormCancelDefault
        }
      });
      dispatch({
        type: 'userInfo/getPasswordRule',
        payload: {
          organizationId: getUserOrganizationId()
        }
      });
    }
  }, {
    key: "handlePasswordUpdate",
    value: function handlePasswordUpdate(fieldsValue) {
      var _this2 = this;

      var _this$props2 = this.props,
          publicKey = _this$props2.publicKey,
          dispatch = _this$props2.dispatch;
      var onPasswordUpdate = this.props.onPasswordUpdate;
      onPasswordUpdate({
        password: encryptPwd(fieldsValue.password, publicKey),
        originalPassword: encryptPwd(fieldsValue.originalPassword, publicKey)
      }).then(function (res) {
        if (res && res.failed) {
          notification.warning({
            message: res.message
          });

          if (res.message === '您的密码错误，还可以尝试0次') {
            dispatch({
              type: 'login/logout'
            });
          }
        } else {
          _this2.handleModalFormCancelDefault();
        }
      });
    }
  }, {
    key: "renderPasswordFormItems",
    value: function renderPasswordFormItems(form) {
      var _this3 = this;

      var _this$props3 = this.props,
          loginName = _this$props3.userInfo.loginName,
          _this$props3$password = _this$props3.passwordTipMsg,
          passwordTipMsg = _this$props3$password === void 0 ? {} : _this$props3$password;
      var getFieldDecorator = form.getFieldDecorator;
      var validateNewPasswordNotSame = this.validateNewPasswordNotSame,
          validatePasswordAnther = this.validatePasswordAnther; // 验证改变了 this

      return [/*#__PURE__*/React.createElement(FormItem, Object.assign({
        required: true,
        key: "originalPassword",
        label: intl.get('ciam.userInfo.model.user.originalPassword').d('原密码')
      }, formItemLayout), getFieldDecorator('originalPassword', {
        validateTrigger: 'onBlur',
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('ciam.userInfo.model.user.originalPassword').d('原密码')
          })
        }, {
          max: 110,
          message: intl.get('cpaas.common.validation.max', {
            max: 110
          })
        }] // 密码字段自动填充 https://developer.mozilla.org/zh-CN/docs/Web/Security/Securing_your_site/Turning_off_form_autocompletion

      })( /*#__PURE__*/React.createElement(Input, {
        type: "password",
        autoComplete: "new-password",
        onChange: function onChange() {
          setTimeout(function () {
            form.validateFields(['password'], {
              force: true
            });
          });
        }
      }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
        required: true,
        key: "password",
        label: intl.get('ciam.userInfo.model.user.password').d('密码')
      }, formItemLayout), getFieldDecorator('password', {
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('ciam.userInfo.model.userInfo.password').d('密码')
          })
        }, {
          validator: function validator(_, value, callback) {
            validatePasswordRule(value, callback, _objectSpread(_objectSpread({}, passwordTipMsg), {}, {
              loginName: loginName
            }));
          }
        }, {
          validator: function validator(_, value, callback) {
            validateNewPasswordNotSame(value, callback, form);
          }
        }, {
          max: 110,
          message: intl.get('cpaas.common.validation.max', {
            max: 110
          })
        }]
      })( /*#__PURE__*/React.createElement(Input, {
        type: "password",
        onChange: function onChange(e) {
          _this3.validatePasswordRepeatForPassword(e, form);
        }
      }))),
      /*#__PURE__*/
      // // 密码输入框改了, 判断是否需要确认密码
      React.createElement(FormItem, Object.assign({
        required: true,
        key: "anotherPassword",
        label: intl.get('ciam.userInfo.model.user.anotherPassword').d('确认密码')
      }, formItemLayout), getFieldDecorator('anotherPassword', {
        rules: [{
          required: true,
          message: intl.get('cpaas.common.validation.notNull', {
            name: intl.get('ciam.userInfo.model.userInfo.anotherPassword').d('确认密码')
          })
        }, {
          validator: function validator(_, value, callback) {
            validatePasswordAnther(value, callback, form);
          }
        }]
      })( /*#__PURE__*/React.createElement(Input, {
        type: "password"
      })))];
    } // phone

  }, {
    key: "renderPhone",
    value: function renderPhone() {
      var _this$props$userInfo2 = this.props.userInfo,
          userInfo = _this$props$userInfo2 === void 0 ? {} : _this$props$userInfo2;
      var btns = [];
      var content = '';

      if (userInfo.phoneCheckFlag === 1) {
        content = /*#__PURE__*/React.createElement("span", {
          className: styles['color-bind']
        }, /*#__PURE__*/React.createElement(Icon, {
          type: "check-circle"
        }), "\xA0", intl.get('ciam.userInfo.view.message.bind').d('已绑定'), "\xA0", userInfo.phone, userInfo.phone ? /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0") : '');
        btns.push( /*#__PURE__*/React.createElement(Button, {
          key: "update",
          onClick: this.handlePhoneEdit
        }, intl.get('cpaas.common.button.update').d('修改')));
      } else {
        content = /*#__PURE__*/React.createElement("span", {
          className: styles['color-unbind']
        }, /*#__PURE__*/React.createElement(Icon, {
          type: "info-circle"
        }), "\xA0", intl.get('ciam.userInfo.view.message.unbind').d('未绑定'), "\xA0", userInfo.phone, userInfo.phone ? /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0") : '');
        btns.push( /*#__PURE__*/React.createElement(Button, {
          key: "bind",
          type: "primary",
          onClick: this.handleUnCheckedPhoneBind
        }, intl.get('ciam.userInfo.view.option.bind').d('绑定')));
      }

      return /*#__PURE__*/React.createElement(MaxLenItem, {
        itemIcon: null,
        content: content,
        className: styles['max-len-item-content-wrapper-safe'],
        description: intl.get('ciam.userInfo.model.user.phoneBind').d('绑定手机'),
        comment: intl.get('ciam.userInfo.view.message.phoneBind').d('可用手机号加密码登录CPAAS，可通过手机号找回密码'),
        btns: btns
      });
    } // email

  }, {
    key: "renderEmail",
    value: function renderEmail() {
      var _this$props$userInfo3 = this.props.userInfo,
          userInfo = _this$props$userInfo3 === void 0 ? {} : _this$props$userInfo3;
      var btns = [];
      var content = '';

      if (userInfo.emailCheckFlag === 1) {
        content = /*#__PURE__*/React.createElement("span", {
          className: styles['color-bind']
        }, /*#__PURE__*/React.createElement(Icon, {
          type: "check-circle"
        }), "\xA0", intl.get('ciam.userInfo.view.message.bind').d('已绑定'), "\xA0", userInfo.email, userInfo.email ? /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0") : '');
        btns.push( /*#__PURE__*/React.createElement(Button, {
          key: "update",
          onClick: this.handleEmailEdit
        }, intl.get('cpaas.common.button.update').d('修改')));
      } else {
        content = /*#__PURE__*/React.createElement("span", {
          className: styles['color-unbind']
        }, /*#__PURE__*/React.createElement(Icon, {
          type: "info-circle"
        }), "\xA0", intl.get('ciam.userInfo.view.message.unbind').d('未绑定'), "\xA0", userInfo.email, userInfo.email ? /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0") : '');
        btns.push( /*#__PURE__*/React.createElement(Button, {
          key: "bind",
          type: "primary",
          onClick: this.handleUnCheckedEmailBind
        }, intl.get('ciam.userInfo.view.option.bind').d('绑定')));
      }

      return /*#__PURE__*/React.createElement(MaxLenItem, {
        itemIcon: null,
        className: styles['max-len-item-content-wrapper-safe'],
        description: intl.get('ciam.userInfo.model.user.emailBind').d('邮箱绑定'),
        content: content,
        comment: intl.get('ciam.userInfo.view.message.emailBind').d('可用邮箱加密码登录CPAAS，可用邮箱找回密码'),
        btns: btns
      });
    } // open-app

  }, {
    key: "renderOpenApp",
    value: function renderOpenApp() {
      var _this4 = this;

      var _this$props$openAccou2 = this.props.openAccountList,
          openAccountList = _this$props$openAccou2 === void 0 ? [] : _this$props$openAccou2;
      return _map(openAccountList, function (openApp) {
        var btns = [];

        if (openApp.openName) {
          btns.push( /*#__PURE__*/React.createElement(Button, {
            key: "unbind",
            className: styles['btn-bind'],
            onClick: _this4.handleUnBindApp.bind(_this4, openApp)
          }, intl.get('ciam.userInfo.view.option.unBind').d('解绑')));
        } else {
          btns.push( /*#__PURE__*/React.createElement(Button, {
            key: "bind",
            type: "primary",
            className: styles['btn-bind'],
            onClick: _this4.handleBindApp.bind(_this4, openApp)
          }, intl.get('ciam.userInfo.view.option.bind').d('绑定')));
        }

        return /*#__PURE__*/React.createElement(MaxLenItem, {
          key: openApp.openAppId,
          icon: /*#__PURE__*/React.createElement("img", {
            src: openApp.appImage,
            alt: "",
            style: {
              height: 36,
              width: 36
            }
          }),
          description: openApp.appName,
          content: openApp.openName || '',
          btns: btns
        });
      });
    }
    /**
     * @function handleBindApp - 获取绑定认证地址
     * @param {object} item - 第三方数据
     */

  }, {
    key: "handleBindApp",
    value: function handleBindApp(item) {
      window.open("".concat(AUTH_HOST, "/open/").concat(item.appCode, "?channel=").concat(item.channel, "&access_token=").concat(getAccessToken(), "&bind_redirect_uri=").concat(encodeURIComponent(window.location)), '_self', 'noopener,noreferrer');
    }
    /**
     * @function handleUnBindApp - 解除第三方绑定
     * @param {object} item - 第三方应用数据
     */

  }, {
    key: "handleUnBindApp",
    value: function handleUnBindApp(item) {
      var _this$props4 = this.props,
          dispatch = _this$props4.dispatch,
          _this$props4$userInfo = _this$props4.userInfo;
      _this$props4$userInfo = _this$props4$userInfo === void 0 ? {} : _this$props4$userInfo;
      var id = _this$props4$userInfo.id;
      Modal.confirm({
        title: "".concat(intl.get('ciam.userInfo.view.confirmUnBind').d('确定解除绑定'), "\uFF1F"),
        onOk: function onOk() {
          dispatch({
            type: 'userInfo/unBindOpenAccount',
            payload: _objectSpread({}, item)
          }).then(function (res) {
            if (res) {
              notification.success(); // dispatch({
              //   type: 'userInfo/fetchOpenAccountList',
              //   payload: { userId: id },
              // });
            }
          });
        }
      });
    } // todo

    /**
     * 发送验证码
     * 旧手机的验证码, 新手机的验证码, 新邮箱的验证码
     * 获取验证码, 使用同一个变量, 要注意使用 和 清除
     * @param {'oldPhone' | 'newPhone' | 'newEmail'} [type='oldPhone'] - 获取哪个验证码
     * @param {!String} value - 对应的手机号 或者 邮箱
     * @param {Object} ...params - 其他参数
     */

  }, {
    key: "handleGainValidCodeBtnClick",
    value: function handleGainValidCodeBtnClick(_ref) {
      var _ref$type = _ref.type,
          type = _ref$type === void 0 ? 'oldPhone' : _ref$type,
          value = _ref.value,
          params = _objectWithoutProperties(_ref, _excluded);

      var _this$props5 = this.props,
          dispatch = _this$props5.dispatch,
          _this$props5$modalPro = _this$props5.modalProps,
          modalProps = _this$props5$modalPro === void 0 ? {} : _this$props5$modalPro;
      dispatch({
        type: 'userInfo/postCaptcha',
        payload: _objectSpread({
          type: type,
          value: value,
          modalProps: modalProps
        }, params)
      });
    }
    /**
     * 解除 - 计时限制
     * 倒计时组件 计时完成后 触发, 取消计时状态
     */

  }, {
    key: "handleValidCodeLimitEnd",
    value: function handleValidCodeLimitEnd() {
      var _this$props6 = this.props,
          dispatch = _this$props6.dispatch,
          _this$props6$modalPro = _this$props6.modalProps,
          modalProps = _this$props6$modalPro === void 0 ? {} : _this$props6$modalPro;
      dispatch({
        type: 'userInfo/captchaLimitEnd',
        payload: {
          modalProps: modalProps
        }
      });
    }
    /**
     * 修改邮箱： 校验身份
     * @memberof UserInfo
     */

  }, {
    key: "handleEmailEdit",
    value: function handleEmailEdit() {
      var email = this.props.userInfo.email; // 修改邮箱 前置校验成功后的回调

      var onNext = this.openUpdateNewEmailForm; // 校验身份, 成功后 打开 修改邮箱的模态框

      this.handleOpenForm(_objectSpread({
        title: intl.get('ciam.userInfo.view.message.title.form.email').d('更改邮箱')
      }, email ? this.getValidateOldEmailFormProps(onNext) : this.getValidatePasswordFormProps(onNext)));
    }
    /**
     * 打开修改邮箱的模态框
     */

  }, {
    key: "openUpdateNewEmailForm",
    value: function openUpdateNewEmailForm() {
      this.handleOpenForm(_objectSpread({}, this.getValidateNewEmailFormProps()));
    }
  }, {
    key: "handleUnCheckedEmailBind",
    value: function handleUnCheckedEmailBind() {
      this.handleOpenForm(this.getValidateUnCheckedEmailFormProps());
    }
    /**
     *查看个人登录记录
     * @memberof SafeInfo
     */

  }, {
    key: "handleCheckLoginLog",
    value: function handleCheckLoginLog() {
      var dispatch = this.props.dispatch;
      dispatch(routerRedux.push({
        pathname: "/ciam/user/login-log"
      }));
    }
    /**
     * 修改手机： 校验身份
     * @memberof UserInfo
     */

  }, {
    key: "handlePhoneEdit",
    value: function handlePhoneEdit() {
      var phone = this.props.userInfo.phone; // 修改手机 前置校验成功后的回调,

      var onNext = this.openUpdateNewPhoneForm; // 校验身份, 成功后 打开 修改手机的模态框

      this.handleOpenForm(_objectSpread({
        title: intl.get('ciam.userInfo.view.message.title.form.phone').d('更改手机号码')
      }, phone ? this.getValidateOldPhoneFormProps(onNext) : this.getValidatePasswordFormProps(onNext)));
    }
  }, {
    key: "handleUnCheckedPhoneBind",
    value: function handleUnCheckedPhoneBind() {
      this.handleOpenForm(this.getValidateUnCheckedPhoneFormProps());
    }
    /**
     * 打开修改手机的模态框
     */

  }, {
    key: "openUpdateNewPhoneForm",
    value: function openUpdateNewPhoneForm() {
      this.handleOpenForm(_objectSpread({}, this.getValidateNewPhoneFormProps()));
    }
    /**
     * 获取 通过邮箱认证身份时的 EditFormModal 的属性
     * @param {Function} onNext - 通过邮箱 认证身份后的 下一步操作
     */

  }, {
    key: "getValidateOldEmailFormProps",
    value: function getValidateOldEmailFormProps(onNext) {
      var _this5 = this;

      var formProps = {
        step: 'validateOldEmail',
        okText: intl.get('cpaas.common.button.next').d('下一步'),
        onCancel: this.handleCloseForm,
        onOk: function onOk(fieldsValue, form) {
          var _this5$props = _this5.props,
              _this5$props$modalPro = _this5$props.modalProps,
              modalProps = _this5$props$modalPro === void 0 ? {} : _this5$props$modalPro,
              dispatch = _this5$props.dispatch;
          var captcha = fieldsValue.captcha;
          form.resetFields();
          dispatch({
            type: 'userInfo/validatePreValidate',
            payload: {
              captcha: captcha,
              type: 'oldEmail',
              modalProps: modalProps,
              businessScope: 'self'
            }
          }).then(function (res) {
            if (res) {
              onNext();
            }
          });
        }
      };

      formProps.formItems = function (form) {
        var getFieldDecorator = form.getFieldDecorator;
        var _this5$props2 = _this5.props,
            userInfo = _this5$props2.userInfo,
            _this5$props2$modalPr = _this5$props2.modalProps,
            validCodeSendLimitFlag = _this5$props2$modalPr.validCodeSendLimitFlag,
            validCodeLimitTimeEnd = _this5$props2$modalPr.validCodeLimitTimeEnd,
            _this5$props2$postCap = _this5$props2.postCaptchaLoading,
            postCaptchaLoading = _this5$props2$postCap === void 0 ? false : _this5$props2$postCap;
        return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormItem, Object.assign({
          required: true,
          label: intl.get('ciam.userInfo.model.user.email').d('邮箱')
        }, formItemLayout), getFieldDecorator('oldEmail', {
          initialValue: userInfo.email
        })( /*#__PURE__*/React.createElement(Input, {
          disabled: true
        }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
          required: true,
          label: intl.get('ciam.userInfo.model.user.emailCaptcha').d('邮箱验证码')
        }, formItemLayout), getFieldDecorator('captcha', {
          validateTrigger: 'onBlur',
          rules: [{
            required: true,
            message: intl.get('cpaas.common.validation.notNull', {
              name: intl.get('ciam.userInfo.model.userInfo.emailCaptcha').d('邮箱验证码')
            })
          }]
        })( /*#__PURE__*/React.createElement(Input, {
          style: {
            width: '257px',
            marginRight: '10px'
          }
        })), /*#__PURE__*/React.createElement(Button, {
          style: {
            width: 90
          },
          loading: postCaptchaLoading,
          disabled: validCodeSendLimitFlag,
          onClick: function onClick() {
            _this5.handleGainValidCodeBtnClick({
              type: 'oldEmail',
              value: userInfo.email,
              businessScope: 'self'
            });
          }
        }, validCodeSendLimitFlag ? /*#__PURE__*/React.createElement(CountDown, {
          target: validCodeLimitTimeEnd,
          onEnd: _this5.handleValidCodeLimitEnd
        }) : intl.get('ciam.userInfo.view.option.gainCaptcha').d('获取验证码'))), /*#__PURE__*/React.createElement("div", {
          style: {
            textAlign: 'right'
          }
        }, /*#__PURE__*/React.createElement("a", {
          onClick: function onClick() {
            _this5.handleOpenForm(_objectSpread({}, _this5.getValidatePasswordFormProps(onNext)));
          }
        }, intl.get('ciam.userInfo.view.message.cantReceiveEmailCaptcha').d('邮箱无法收到验证码'), "\uFF1F")));
      };

      return formProps;
    }
    /**
     * 获取 通过手机认证身份时的 EditFormModal 的属性
     * @param {Function} onNext - 通过手机 认证身份后的 下一步操作
     */

  }, {
    key: "getValidateOldPhoneFormProps",
    value: function getValidateOldPhoneFormProps(onNext) {
      var _this6 = this;

      var phoneCheckFlag = this.props.userInfo.phoneCheckFlag;

      if (phoneCheckFlag !== 1) {
        // 手机号 没有经过 校验, 则只能通过密码校验
        return this.getValidatePasswordFormProps(onNext);
      }

      var formProps = {
        step: 'validateOldPhone',
        okText: intl.get('cpaas.common.button.next').d('下一步'),
        onCancel: this.handleCloseForm,
        onOk: function onOk(fieldsValue, form) {
          var _this6$props = _this6.props,
              _this6$props$modalPro = _this6$props.modalProps,
              modalProps = _this6$props$modalPro === void 0 ? {} : _this6$props$modalPro,
              dispatch = _this6$props.dispatch;
          var captcha = fieldsValue.captcha;
          form.resetFields();
          dispatch({
            type: 'userInfo/validatePreValidate',
            payload: {
              captcha: captcha,
              type: 'oldPhone',
              modalProps: modalProps,
              businessScope: 'self'
            }
          }).then(function (res) {
            if (res) {
              onNext();
            }
          });
        }
      };

      formProps.formItems = function (form) {
        var getFieldDecorator = form.getFieldDecorator;
        var _this6$props2 = _this6.props,
            userInfo = _this6$props2.userInfo,
            _this6$props2$modalPr = _this6$props2.modalProps,
            validCodeSendLimitFlag = _this6$props2$modalPr.validCodeSendLimitFlag,
            validCodeLimitTimeEnd = _this6$props2$modalPr.validCodeLimitTimeEnd,
            _this6$props2$postCap = _this6$props2.postCaptchaLoading,
            postCaptchaLoading = _this6$props2$postCap === void 0 ? false : _this6$props2$postCap;
        return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormItem, Object.assign({
          required: true,
          label: intl.get('ciam.userInfo.model.user.phone').d('手机号码')
        }, formItemLayout), getFieldDecorator('oldPhone', {
          initialValue: userInfo.phone
        })( /*#__PURE__*/React.createElement(Input, {
          disabled: true
        }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
          required: true,
          label: intl.get('ciam.userInfo.model.user.phoneCaptcha').d('短信验证码')
        }, formItemLayout), getFieldDecorator('captcha', {
          validateTrigger: 'onBlur',
          rules: [{
            required: true,
            message: intl.get('cpaas.common.validation.notNull', {
              name: intl.get('ciam.userInfo.model.userInfo.phoneCaptcha').d('短信验证码')
            })
          }]
        })( /*#__PURE__*/React.createElement(Input, {
          style: {
            width: 257,
            marginRight: 10
          }
        })), /*#__PURE__*/React.createElement(Button, {
          style: {
            width: 90
          },
          disabled: validCodeSendLimitFlag,
          loading: postCaptchaLoading,
          onClick: function onClick() {
            _this6.handleGainValidCodeBtnClick({
              type: 'oldPhone',
              value: userInfo.phone,
              businessScope: 'self'
            });
          }
        }, validCodeSendLimitFlag ? /*#__PURE__*/React.createElement(CountDown, {
          target: validCodeLimitTimeEnd,
          onEnd: _this6.handleValidCodeLimitEnd
        }) : intl.get('ciam.userInfo.view.option.gainCaptcha').d('获取验证码'))), /*#__PURE__*/React.createElement("div", {
          style: {
            textAlign: 'right'
          }
        }, /*#__PURE__*/React.createElement("a", {
          onClick: function onClick() {
            _this6.handleOpenForm(_objectSpread({}, _this6.getValidatePasswordFormProps(onNext)));
          }
        }, intl.get('ciam.userInfo.view.message.cantReceivePhoneCaptcha').d('手机无法接收验证码'), "\uFF1F")));
      };

      return formProps;
    }
    /**
     * 获取 通过密码认证身份时的 EditFormModal 的属性
     * @param {Function} onNext - 通过密码 认证身份后的 下一步操作
     */

  }, {
    key: "getValidatePasswordFormProps",
    value: function getValidatePasswordFormProps(onNext) {
      var _this7 = this;

      var publicKey = this.props.publicKey;
      var formProps = {
        step: 'validatePassword',
        okText: intl.get('cpaas.common.button.next').d('下一步'),
        onCancel: this.handleCloseForm,
        onOk: function onOk(fieldsValue, form) {
          var _this7$props = _this7.props,
              _this7$props$modalPro = _this7$props.modalProps,
              modalProps = _this7$props$modalPro === void 0 ? {} : _this7$props$modalPro,
              dispatch = _this7$props.dispatch;
          var captcha = fieldsValue.captcha;
          form.resetFields();
          dispatch({
            type: 'userInfo/validatePreValidate',
            payload: {
              captcha: captcha,
              captchaKey: modalProps.captchaKey,
              modalProps: modalProps,
              businessScope: 'self'
            }
          }).then(function (res) {
            if (res) {
              onNext();
            }
          });
        }
      };

      formProps.formItems = function (form) {
        var getFieldDecorator = form.getFieldDecorator;
        return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormItem, Object.assign({
          required: true,
          label: intl.get('ciam.userInfo.model.user.originalPassword').d('原密码')
        }, formItemLayout), getFieldDecorator('password', {
          validateTrigger: 'onBlur',
          rules: [{
            required: true,
            message: intl.get('cpaas.common.validation.notNull', {
              name: intl.get('ciam.userInfo.model.user.originalPassword').d('原密码')
            })
          }]
        })( /*#__PURE__*/React.createElement(Input, {
          type: "password"
        }))));
      };

      formProps.onOk = function (fieldsValue) {
        var password = fieldsValue.password;
        var _this7$props2 = _this7.props,
            _this7$props2$modalPr = _this7$props2.modalProps,
            modalProps = _this7$props2$modalPr === void 0 ? {} : _this7$props2$modalPr,
            dispatch = _this7$props2.dispatch;
        dispatch({
          type: 'userInfo/validatePrePassword',
          payload: {
            password: encryptPwd(password, publicKey),
            modalProps: modalProps,
            businessScope: 'self'
          }
        }).then(function (res) {
          if (res) {
            if (_isFunction(onNext)) {
              onNext();
            }
          }
        });
      };

      return formProps;
    }
    /**
     * 获取 修改邮箱时 EditFormModal 的属性
     */

  }, {
    key: "getValidateNewEmailFormProps",
    value: function getValidateNewEmailFormProps() {
      var _this8 = this;

      var formProps = {
        title: intl.get('ciam.userInfo.view.message.title.form.email').d('更改邮箱'),
        step: 'validateNewEmail',
        onCancel: this.handleCloseForm,
        onOk: function onOk(fieldsValue, form) {
          var captcha = fieldsValue.captcha,
              newEmail = fieldsValue.newEmail; // 新的邮箱的 验证 key

          var _this8$props = _this8.props,
              _this8$props$userInfo = _this8$props.userInfo,
              userInfo = _this8$props$userInfo === void 0 ? {} : _this8$props$userInfo,
              _this8$props$modalPro = _this8$props.modalProps,
              lastCheckKey = _this8$props$modalPro.lastCheckKey,
              emailCaptchaKey = _this8$props$modalPro.captchaKey,
              dispatch = _this8$props.dispatch;
          dispatch({
            type: 'userInfo/validateNewEmail',
            payload: {
              email: newEmail,
              captcha: captcha,
              captchaKey: emailCaptchaKey,
              lastCheckKey: lastCheckKey,
              userInfo: userInfo,
              businessScope: 'self'
            }
          }).then(function (res) {
            if (res) {
              form.resetFields();

              _this8.handleCloseForm();
            }
          });
        },
        formItems: function formItems(form) {
          var getFieldDecorator = form.getFieldDecorator;
          var _this8$props2 = _this8.props,
              _this8$props2$modalPr = _this8$props2.modalProps,
              validCodeSendLimitFlag = _this8$props2$modalPr.validCodeSendLimitFlag,
              validCodeLimitTimeEnd = _this8$props2$modalPr.validCodeLimitTimeEnd,
              _this8$props2$postCap = _this8$props2.postCaptchaLoading,
              postCaptchaLoading = _this8$props2$postCap === void 0 ? false : _this8$props2$postCap;
          return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormItem, Object.assign({
            required: true,
            label: intl.get('ciam.userInfo.model.user.email').d('邮箱')
          }, formItemLayout), getFieldDecorator('newEmail', {
            validateTrigger: 'onBlur',
            validateFirst: true,
            rules: [{
              required: true,
              message: intl.get('cpaas.common.validation.notNull', {
                name: intl.get('ciam.userInfo.model.user.email').d('邮箱')
              })
            }, {
              pattern: EMAIL,
              message: intl.get('cpaas.common.validation.email').d('邮箱格式不正确')
            }, {
              validator: _this8.validateEmailIsNoLastEmail
            }, {
              validator: _this8.validateEmailRegister
            }]
          })( /*#__PURE__*/React.createElement(Input, null))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
            required: true,
            label: intl.get('ciam.userInfo.model.user.emailCaptcha').d('邮箱验证码')
          }, formItemLayout), getFieldDecorator('captcha', {
            validateTrigger: 'onBlur',
            rules: [{
              required: true,
              message: intl.get('cpaas.common.validation.notNull', {
                name: intl.get('ciam.userInfo.model.user.emailCaptcha').d('邮箱验证码')
              })
            }]
          })( /*#__PURE__*/React.createElement(Input, {
            style: {
              width: 257,
              marginRight: 10
            }
          })), /*#__PURE__*/React.createElement(Button, {
            style: {
              width: 90
            },
            disabled: validCodeSendLimitFlag,
            loading: postCaptchaLoading,
            onClick: function onClick() {
              var lastCheckKey = _this8.props.modalProps.lastCheckKey;
              form.validateFields(['newEmail'], function (err, fieldsValue) {
                if (!err) {
                  _this8.handleGainValidCodeBtnClick({
                    type: 'newEmail',
                    lastCheckKey: lastCheckKey,
                    value: fieldsValue.newEmail,
                    businessScope: 'self'
                  });
                }
              });
            }
          }, validCodeSendLimitFlag ? /*#__PURE__*/React.createElement(CountDown, {
            target: validCodeLimitTimeEnd,
            onEnd: _this8.handleValidCodeLimitEnd,
            disabled: !!form.getFieldError('newEmail')
          }) : intl.get('ciam.userInfo.view.option.gainCaptcha').d('获取验证码'))));
        }
      };
      return formProps;
    }
    /**
     * 绑定邮箱 | 验证未验证的邮箱
     * 验证未验证的邮箱: 给邮箱发送验证码 后 修改邮箱
     * 绑定邮箱: 验证身份 后 修改邮箱
     */

  }, {
    key: "getValidateUnCheckedEmailFormProps",
    value: function getValidateUnCheckedEmailFormProps() {
      var _this9 = this;

      var _this$props$userInfo4 = this.props.userInfo,
          email = _this$props$userInfo4.email,
          emailCheckFlag = _this$props$userInfo4.emailCheckFlag;
      var formProps;

      if (emailCheckFlag !== 1 && !email) {
        // 绑定邮箱
        formProps = this.getValidateOldPhoneFormProps(this.openUpdateNewEmailForm);
      } else {
        // 验证邮箱
        formProps = {
          step: 'validateUnCheckedEmail',
          onCancel: this.handleCloseForm,
          onOk: function onOk(fieldsValue, form) {
            var captcha = fieldsValue.captcha; // 新的邮箱的 验证 key

            var _this9$props = _this9.props,
                emailCaptchaKey = _this9$props.modalProps.captchaKey,
                _this9$props$userInfo = _this9$props.userInfo,
                userInfo = _this9$props$userInfo === void 0 ? {} : _this9$props$userInfo,
                dispatch = _this9$props.dispatch;
            dispatch({
              type: 'userInfo/validateUnCheckedEmail',
              payload: {
                captcha: captcha,
                captchaKey: emailCaptchaKey,
                userInfo: userInfo,
                businessScope: 'self'
              }
            }).then(function (res) {
              if (res) {
                form.resetFields();

                _this9.handleCloseForm();
              }
            });
          },
          formItems: function formItems(form) {
            var getFieldDecorator = form.getFieldDecorator;
            var _this9$props2 = _this9.props,
                _this9$props2$modalPr = _this9$props2.modalProps,
                validCodeSendLimitFlag = _this9$props2$modalPr.validCodeSendLimitFlag,
                validCodeLimitTimeEnd = _this9$props2$modalPr.validCodeLimitTimeEnd,
                _this9$props2$userInf = _this9$props2.userInfo,
                userInfo = _this9$props2$userInf === void 0 ? {} : _this9$props2$userInf,
                _this9$props2$postCap = _this9$props2.postCaptchaLoading,
                postCaptchaLoading = _this9$props2$postCap === void 0 ? false : _this9$props2$postCap;
            return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormItem, Object.assign({
              required: true,
              label: intl.get('ciam.userInfo.model.user.email').d('邮箱')
            }, formItemLayout), getFieldDecorator('oldEmail', {
              initialValue: userInfo.email,
              validateTrigger: 'onBlur',
              validateFirst: true,
              rules: [{
                required: true,
                message: intl.get('cpaas.common.validation.notNull', {
                  name: intl.get('ciam.userInfo.model.user.email').d('邮箱')
                })
              }, {
                pattern: EMAIL,
                message: intl.get('cpaas.common.validation.email').d('邮箱格式不正确')
              }]
            })( /*#__PURE__*/React.createElement(Input, {
              disabled: true
            }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
              required: true,
              label: intl.get('ciam.userInfo.model.user.emailCaptcha').d('邮箱验证码')
            }, formItemLayout), getFieldDecorator('captcha', {
              validateTrigger: 'onBlur',
              rules: [{
                required: true,
                message: intl.get('cpaas.common.validation.notNull', {
                  name: intl.get('ciam.userInfo.model.user.emailCaptcha').d('邮箱验证码')
                })
              }]
            })( /*#__PURE__*/React.createElement(Input, {
              style: {
                width: 257,
                marginRight: 10
              }
            })), /*#__PURE__*/React.createElement(Button, {
              style: {
                width: 90
              },
              disabled: validCodeSendLimitFlag,
              loading: postCaptchaLoading,
              onClick: function onClick() {
                form.validateFields(['oldEmail'], function (err, fieldsValue) {
                  if (!err) {
                    _this9.handleGainValidCodeBtnClick({
                      type: 'oldEmail',
                      value: fieldsValue.oldEmail,
                      businessScope: 'self'
                    });
                  }
                });
              }
            }, validCodeSendLimitFlag ? /*#__PURE__*/React.createElement(CountDown, {
              target: validCodeLimitTimeEnd,
              onEnd: _this9.handleValidCodeLimitEnd,
              disabled: !!form.getFieldError('oldEmail')
            }) : intl.get('ciam.userInfo.view.option.gainCaptcha').d('获取验证码'))));
          }
        };
      }

      formProps.title = intl.get('ciam.userInfo.view.message.title.form.unCheckedEmail').d('绑定邮箱');
      return formProps;
    }
    /**
     * 获取 修改手机时 EditFormModal 的属性
     */

  }, {
    key: "getValidateNewPhoneFormProps",
    value: function getValidateNewPhoneFormProps() {
      var _this10 = this;

      var formProps = {
        title: intl.get('ciam.userInfo.view.message.title.form.phone').d('更改手机号码'),
        step: 'validateNewPhone',
        onCancel: this.handleCloseForm,
        onOk: function onOk(fieldsValue, form) {
          var captcha = fieldsValue.captcha,
              newPhone = fieldsValue.newPhone; // 新的邮箱的 验证 key

          var _this10$props = _this10.props,
              _this10$props$modalPr = _this10$props.modalProps,
              lastCheckKey = _this10$props$modalPr.lastCheckKey,
              phoneCaptchaKey = _this10$props$modalPr.captchaKey,
              _this10$props$userInf = _this10$props.userInfo,
              userInfo = _this10$props$userInf === void 0 ? {} : _this10$props$userInf,
              dispatch = _this10$props.dispatch;
          dispatch({
            type: 'userInfo/validateNewPhone',
            payload: {
              phone: newPhone,
              captcha: captcha,
              captchaKey: phoneCaptchaKey,
              lastCheckKey: lastCheckKey,
              userInfo: userInfo,
              businessScope: 'self'
            }
          }).then(function (res) {
            if (res) {
              form.resetFields();

              _this10.handleCloseForm();
            }
          });
        },
        formItems: function formItems(form) {
          var getFieldDecorator = form.getFieldDecorator;
          var _this10$props2 = _this10.props,
              _this10$props2$modalP = _this10$props2.modalProps,
              validCodeSendLimitFlag = _this10$props2$modalP.validCodeSendLimitFlag,
              validCodeLimitTimeEnd = _this10$props2$modalP.validCodeLimitTimeEnd,
              _this10$props2$postCa = _this10$props2.postCaptchaLoading,
              postCaptchaLoading = _this10$props2$postCa === void 0 ? false : _this10$props2$postCa;
          return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormItem, Object.assign({
            required: true,
            label: intl.get('ciam.userInfo.model.user.phone').d('手机号码')
          }, formItemLayout), getFieldDecorator('newPhone', {
            validateTrigger: 'onBlur',
            validateFirst: true,
            rules: [{
              required: true,
              message: intl.get('cpaas.common.validation.notNull', {
                name: intl.get('ciam.userInfo.model.user.phone').d('手机号码')
              })
            }, {
              pattern: PHONE,
              message: intl.get('cpaas.common.validation.phone').d('手机格式不正确')
            }, {
              validator: _this10.validatePhoneIsNoLastPhone
            }, {
              validator: _this10.validatePhoneRegister
            }]
          })( /*#__PURE__*/React.createElement(Input, null))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
            required: true,
            label: intl.get('ciam.userInfo.model.user.phoneCaptcha').d('短信验证码')
          }, formItemLayout), getFieldDecorator('captcha', {
            validateTrigger: 'onBlur',
            rules: [{
              required: true,
              message: intl.get('cpaas.common.validation.notNull', {
                name: intl.get('ciam.userInfo.model.user.phoneCaptcha').d('短信验证码')
              })
            }]
          })( /*#__PURE__*/React.createElement(Input, {
            style: {
              width: 257,
              marginRight: 10
            }
          })), /*#__PURE__*/React.createElement(Button, {
            style: {
              width: 90
            },
            disabled: validCodeSendLimitFlag,
            loading: postCaptchaLoading,
            onClick: function onClick() {
              var lastCheckKey = _this10.props.modalProps.lastCheckKey;
              form.validateFields(['newPhone'], function (err, fieldsValue) {
                if (!err) {
                  _this10.handleGainValidCodeBtnClick({
                    type: 'newPhone',
                    lastCheckKey: lastCheckKey,
                    value: fieldsValue.newPhone,
                    businessScope: 'self'
                  });
                }
              });
            }
          }, validCodeSendLimitFlag ? /*#__PURE__*/React.createElement(CountDown, {
            target: validCodeLimitTimeEnd,
            onEnd: _this10.handleValidCodeLimitEnd,
            disabled: !!form.getFieldError('newPhone')
          }) : intl.get('ciam.userInfo.view.option.gainCaptcha').d('获取验证码'))));
        }
      };
      return formProps;
    }
    /**
     * 绑定手机号的表单
     * @returns {{title: *, step: string, onCancel: UserInfo.handleCloseForm, onOk: onOk, formItems: (function(*): *)}}
     */

  }, {
    key: "getValidateUnCheckedPhoneFormProps",
    value: function getValidateUnCheckedPhoneFormProps() {
      var _this11 = this;

      var formProps = {
        title: intl.get('ciam.userInfo.view.message.title.form.unCheckedPhone').d('绑定手机号码'),
        step: 'validateUnCheckedPhone',
        onCancel: this.handleCloseForm,
        onOk: function onOk(fieldsValue, form) {
          var captcha = fieldsValue.captcha; // 新的邮箱的 验证 key

          var _this11$props = _this11.props,
              phoneCaptchaKey = _this11$props.modalProps.captchaKey,
              _this11$props$userInf = _this11$props.userInfo,
              userInfo = _this11$props$userInf === void 0 ? {} : _this11$props$userInf,
              dispatch = _this11$props.dispatch;
          dispatch({
            type: 'userInfo/validateUnCheckedPhone',
            payload: {
              captcha: captcha,
              captchaKey: phoneCaptchaKey,
              userInfo: userInfo,
              businessScope: 'self'
            }
          }).then(function (res) {
            if (res) {
              form.resetFields();

              _this11.handleCloseForm();
            }
          });
        },
        formItems: function formItems(form) {
          var getFieldDecorator = form.getFieldDecorator;
          var _this11$props2 = _this11.props,
              _this11$props2$modalP = _this11$props2.modalProps,
              validCodeSendLimitFlag = _this11$props2$modalP.validCodeSendLimitFlag,
              validCodeLimitTimeEnd = _this11$props2$modalP.validCodeLimitTimeEnd,
              _this11$props2$userIn = _this11$props2.userInfo,
              userInfo = _this11$props2$userIn === void 0 ? {} : _this11$props2$userIn,
              _this11$props2$postCa = _this11$props2.postCaptchaLoading,
              postCaptchaLoading = _this11$props2$postCa === void 0 ? false : _this11$props2$postCa;
          return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormItem, Object.assign({
            required: true,
            label: intl.get('ciam.userInfo.model.user.phone').d('手机号码')
          }, formItemLayout), getFieldDecorator('oldPhone', {
            initialValue: userInfo.phone,
            validateTrigger: 'onBlur',
            validateFirst: true,
            rules: [{
              required: true,
              message: intl.get('cpaas.common.validation.notNull', {
                name: intl.get('ciam.userInfo.model.user.phone').d('手机号码')
              })
            }, {
              pattern: PHONE,
              message: intl.get('cpaas.common.validation.phone').d('手机格式不正确')
            }]
          })( /*#__PURE__*/React.createElement(Input, {
            disabled: true
          }))), /*#__PURE__*/React.createElement(FormItem, Object.assign({
            required: true,
            label: intl.get('ciam.userInfo.model.user.phoneCaptcha').d('短信验证码')
          }, formItemLayout), getFieldDecorator('captcha', {
            validateTrigger: 'onBlur',
            rules: [{
              required: true,
              message: intl.get('cpaas.common.validation.notNull', {
                name: intl.get('ciam.userInfo.model.user.phoneCaptcha').d('短信验证码')
              })
            }]
          })( /*#__PURE__*/React.createElement(Input, {
            style: {
              width: 257,
              marginRight: 10
            }
          })), /*#__PURE__*/React.createElement(Button, {
            style: {
              width: 90
            },
            disabled: validCodeSendLimitFlag,
            loading: postCaptchaLoading,
            onClick: function onClick() {
              form.validateFields(['oldPhone'], function (err, fieldsValue) {
                if (!err) {
                  _this11.handleGainValidCodeBtnClick({
                    type: 'oldPhone',
                    value: fieldsValue.oldPhone,
                    businessScope: 'self'
                  });
                }
              });
            }
          }, validCodeSendLimitFlag ? /*#__PURE__*/React.createElement(CountDown, {
            target: validCodeLimitTimeEnd,
            onEnd: _this11.handleValidCodeLimitEnd,
            disabled: !!form.getFieldError('oldPhone')
          }) : intl.get('ciam.userInfo.view.option.gainCaptcha').d('获取验证码'))));
        }
      };
      return formProps;
    }
    /**
     * handleOpenForm - 打开模态框
     * @param {Object} payload - modalProps 的数据
     */

  }, {
    key: "handleOpenForm",
    value: function handleOpenForm(payload) {
      var _this$props7 = this.props,
          dispatch = _this$props7.dispatch,
          _this$props7$modalPro = _this$props7.modalProps,
          modalProps = _this$props7$modalPro === void 0 ? {} : _this$props7$modalPro;
      dispatch({
        type: 'userInfo/openForm',
        payload: _objectSpread(_objectSpread({}, payload), {}, {
          modalProps: modalProps
        })
      });
    }
    /**
     * 关闭模态框
     */

  }, {
    key: "handleCloseForm",
    value: function handleCloseForm() {
      var _this$props8 = this.props,
          dispatch = _this$props8.dispatch,
          _this$props8$modalPro = _this$props8.modalProps,
          modalProps = _this$props8$modalPro === void 0 ? {} : _this$props8$modalPro;
      dispatch({
        type: 'userInfo/closeForm',
        payload: {
          modalProps: modalProps
        }
      });
    } // validations

    /**
     * validatePasswordAnther - 验证 新密码 和 确认密码 相同
     * @param {String} value - 新的密码
     * @param {Function} callback - 校验失败 需要回调错误， 否则空的回调
     * @param {Object} form - 表单
     * @memberof UserInfo
     */

  }, {
    key: "validatePasswordAnther",
    value: function validatePasswordAnther(value, callback, form) {
      if (value && value !== form.getFieldValue('password')) {
        callback(intl.get('ciam.userInfo.view.validation.passwordSame').d('确认密码必须与密码相同'));
      } else {
        callback();
      }
    }
    /**
     * 检查 确认密码是否与密码一致
     */

  }, {
    key: "validatePasswordRepeatForPassword",
    value: function validatePasswordRepeatForPassword(e, form) {
      var anotherPassword = form.getFieldValue('anotherPassword');
      var anotherPasswordField = {
        value: anotherPassword
      };

      if (e.target.value) {
        if (e.target.value === anotherPassword) {
          anotherPasswordField.errors = null;
        } else {
          anotherPasswordField.errors = [new Error(intl.get('ciam.userInfo.view.validation.passwordSame').d('确认密码必须与密码相同'))];
        }
      } else {
        anotherPasswordField.errors = null;
      }

      form.setFields({
        anotherPassword: anotherPasswordField
      });
    }
    /**
     * validateNewPasswordNotSame - 验证新密码 不能和 旧密码 相同
     * @param {String} value - 新的密码
     * @param {Function} callback - 校验失败 需要回调错误， 否则空的回调
     * @param {Object} form - 表单
     * @memberof UserInfo
     */

  }, {
    key: "validateNewPasswordNotSame",
    value: function validateNewPasswordNotSame(value, callback, form) {
      if (value && value === form.getFieldValue('originalPassword')) {
        callback(intl.get('ciam.userInfo.view.validation.passwordNoSame').d('新密码不能与原密码相同'));
      } else {
        callback();
      }
    }
  }]);

  return SafeInfo;
}(React.Component), (_applyDecoratedDescriptor(_class.prototype, "handleModalFormCancelDefault", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "handleModalFormCancelDefault"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handlePasswordEdit", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "handlePasswordEdit"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handlePasswordUpdate", [_dec3], Object.getOwnPropertyDescriptor(_class.prototype, "handlePasswordUpdate"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "renderPasswordFormItems", [_dec4], Object.getOwnPropertyDescriptor(_class.prototype, "renderPasswordFormItems"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleGainValidCodeBtnClick", [_dec5], Object.getOwnPropertyDescriptor(_class.prototype, "handleGainValidCodeBtnClick"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleValidCodeLimitEnd", [_dec6], Object.getOwnPropertyDescriptor(_class.prototype, "handleValidCodeLimitEnd"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleEmailEdit", [_dec7], Object.getOwnPropertyDescriptor(_class.prototype, "handleEmailEdit"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "openUpdateNewEmailForm", [_dec8], Object.getOwnPropertyDescriptor(_class.prototype, "openUpdateNewEmailForm"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleUnCheckedEmailBind", [_dec9], Object.getOwnPropertyDescriptor(_class.prototype, "handleUnCheckedEmailBind"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleCheckLoginLog", [_dec10], Object.getOwnPropertyDescriptor(_class.prototype, "handleCheckLoginLog"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handlePhoneEdit", [_dec11], Object.getOwnPropertyDescriptor(_class.prototype, "handlePhoneEdit"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleUnCheckedPhoneBind", [_dec12], Object.getOwnPropertyDescriptor(_class.prototype, "handleUnCheckedPhoneBind"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "openUpdateNewPhoneForm", [_dec13], Object.getOwnPropertyDescriptor(_class.prototype, "openUpdateNewPhoneForm"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getValidateOldEmailFormProps", [_dec14], Object.getOwnPropertyDescriptor(_class.prototype, "getValidateOldEmailFormProps"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getValidateOldPhoneFormProps", [_dec15], Object.getOwnPropertyDescriptor(_class.prototype, "getValidateOldPhoneFormProps"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getValidatePasswordFormProps", [_dec16], Object.getOwnPropertyDescriptor(_class.prototype, "getValidatePasswordFormProps"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getValidateNewEmailFormProps", [_dec17], Object.getOwnPropertyDescriptor(_class.prototype, "getValidateNewEmailFormProps"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getValidateUnCheckedEmailFormProps", [_dec18], Object.getOwnPropertyDescriptor(_class.prototype, "getValidateUnCheckedEmailFormProps"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getValidateNewPhoneFormProps", [_dec19], Object.getOwnPropertyDescriptor(_class.prototype, "getValidateNewPhoneFormProps"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "getValidateUnCheckedPhoneFormProps", [_dec20], Object.getOwnPropertyDescriptor(_class.prototype, "getValidateUnCheckedPhoneFormProps"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleOpenForm", [_dec21], Object.getOwnPropertyDescriptor(_class.prototype, "handleOpenForm"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleCloseForm", [_dec22], Object.getOwnPropertyDescriptor(_class.prototype, "handleCloseForm"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "validatePasswordAnther", [_dec23], Object.getOwnPropertyDescriptor(_class.prototype, "validatePasswordAnther"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "validatePasswordRepeatForPassword", [_dec24], Object.getOwnPropertyDescriptor(_class.prototype, "validatePasswordRepeatForPassword"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "validateNewPasswordNotSame", [_dec25], Object.getOwnPropertyDescriptor(_class.prototype, "validateNewPasswordNotSame"), _class.prototype)), _class));
export { SafeInfo as default };